export default {
  /* doneCount(state){
     return state.datas.reduce((total, data) => total + (data.isDone ? 1 : 0), 0);
   }*/
  tableHasSelected(state){
    let count = 0;
    if (!state.currentLinkInfo) {
      return false;
    }
    if (!state.currentLinkInfo.databases) {
      return false;
    }
    let currentLinkInfoDatabases = state.currentLinkInfo.databases;

    currentLinkInfoDatabases.forEach(d => {
      d.tables.forEach(t => {
        if (t.checked) {
          count++;
        }
      });
    });
    console.log("被选择的表数量是:"+count);
    return count > 0;
  },
  isSingleTable(state) {
    let count = 0;
    let currentLinkInfoDatabases = state.currentLinkInfo.databases;
    console.log(JSON.stringify(currentLinkInfoDatabases));
    currentLinkInfoDatabases.forEach(d => {
      d.tables.forEach(t => {
        if (t.checked) {
          count++;
        }
      });
    });
    return count === 1;
  },
  mappingModalShow(state) {
    return state.mappingModalShow;
  },
  singleTableMappingModalShow(state) {
    return state.singleTableMappingModalShow;
  },
  chooseSettingModalShow(state) {
    return state.chooseSettingModalShow;
  },
  editLinkModalShow(state) {
    return state.editLinkModalShow;
  },
  deleteLinkModalShow(state) {
    return state.deleteLinkModalShow;
  },
  createLinkModalShow(state) {
    return state.createLinkModalShow;
  },
  saveSettingModalShow(state) {
    return state.saveSettingModalShow;
  },
  infoModalShow(state) {
    return state.infoModalShow;
  },
  projectSetting(state) {
    return state.projectSetting;
  },
  entitySetting(state) {
    return state.entitySetting;
  },
  mapperSetting(state) {
    return state.mapperSetting;
  },
  serviceSetting(state) {
    return state.serviceSetting;
  },
  controllerSetting(state) {
    return state.controllerSetting;
  },
  linkInfos(state) {
    return state.linkInfos;
  },
  javaTypes(state) {
    return state.javaTypes;
  },
  checkAll(state) {
    if (!state.currentDatabase) {
      return false;
    }
    let tables = state.currentDatabase.tables;
    let checkedTableCount = tables.filter(table => table.checked).length;
    return checkedTableCount === tables.length && checkedTableCount > 0;
  }
}
